package sandbox.controller;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;

import sandbox.model.SampleInfo;
import sandbox.service.RankingService;
import sandbox.service.SampleService;

public class RedirectController extends Controller {

    public Navigation run() {
        String key = asString("key");
        SampleInfo sample = SampleService.getSample(Datastore.stringToKey(key));

        RankingService.click(sample);

        return redirect(sample.getUrl());
    }
}
